﻿using System.Web.Http.Dependencies;
using Ninject;

namespace Spotted.WebApi.Core
{
    public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver
    {
        private readonly IKernel _ninjectKernel;

        public NinjectDependencyResolver(IKernel kernel) : base(kernel)
        {
            // assign the instance
            _ninjectKernel = kernel;
        }

        #region Implementation of IDependencyScope 

        public IDependencyScope BeginScope()
        {
            return new NinjectDependencyScope(_ninjectKernel.BeginBlock());
        }

        #endregion
    }
}